home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / lt_handleinput.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  48KB  |  2,190 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <clib/keymap_protos.h>
  17. #include <pragmas/keymap_pragmas.h>
  18.  
  19. /*****************************************************************************/
  20.  
  21. #include "Assert.h"
  22.  
  23. /*****************************************************************************/
  24.  
  25. STATIC LONG
  26. CurrentWrap(ObjectNode *Node,LONG Current)
  27. {
  28.     if(Current > Node->Max)
  29.         Current = Node->Min;
  30.     else
  31.     {
  32.         if(Current < Node->Min)
  33.             Current = Node->Max;
  34.     }
  35.  
  36.     return(Current);
  37. }
  38.  
  39. STATIC BOOL
  40. CurrentInBounds(ObjectNode *Node,LONG Current)
  41. {
  42.     return((BOOL)(Node->Min <= Current && Current <= Node->Max && Current != Node->Current));
  43. }
  44.  
  45. /****** gtlayout.library/LT_HandleInput ******************************************
  46. *
  47. *   NAME
  48. *    LT_HandleInput -- Filter IntuiMessage data.
  49. *
  50. *   SYNOPSIS
  51. *    LT_HandleInput(Handle,Qualifier,Class,Code,Gadget);
  52. *                     A0      D0      A1    A2    A3
  53. *
  54. *    VOID LT_HandleInput(LayoutHandle *,ULONG,ULONG *,
  55. *                        UWORD *,struct Gadget **);
  56. *
  57. *   FUNCTION
  58. *    In order to keep track of user interface actions, such as
  59. *    keys getting pressed, sliders getting moved, etc. your
  60. *    code is to call LT_HandleInput() with data copied from the
  61. *    IntuiMessage it has just received and replied.
  62. *
  63. *   INPUTS
  64. *    Handle - Pointer to a LayoutHandle structure.
  65. *
  66. *    Qualifier - The Qualifier value copied from the
  67. *        IntuiMessage structure.
  68. *
  69. *    Class - Pointer to the ULONG variable which holds the
  70. *        value copied from the Class entry of the
  71. *        IntuiMessage structure.
  72. *
  73. *    Code - Pointer to the UWORD variable which holds the
  74. *        value copied from the Code entry of the
  75. *        IntuiMessage structure.
  76. *
  77. *    Gadget - Pointer to the Gadget value copied from the
  78. *        IAddress entry of the IntuiMessage structure.
  79. *
  80. *   RESULT
  81. *    none
  82. *
  83. *   EXAMPLE
  84. *    struct IntuiMessage *IntuiMessage;
  85. *    ULONG Qualifier,Class;
  86. *    UWORD Code;
  87. *    struct Gadget *Gadget;
  88. *
  89. *    for(;;)
  90. *    {
  91. *        WaitPort(Window->UserPort);
  92. *
  93. *        while(IntuiMessage = GT_GetIMsg(Window->UserPort))
  94. *        {
  95. *            Class = IntuiMessage->Class;
  96. *            Code = IntuiMessage->Code;
  97. *            Qualifier = IntuiMessage->Qualifier;
  98. *            Gadget = IntuiMessage->Gadget;
  99. *
  100. *            GT_ReplyIMsg(IntuiMessage);
  101. *
  102. *            LT_HandleInput(Handle,Qualifier,&Class,&Code,&Gadget);
  103. *        }
  104. *    }
  105. *
  106. *   NOTES
  107. *    For BOOPSI_KIND objects keystroke activation may lead to
  108. *    unexpected results. Your application will hear a IDCMP_GADGETUP
  109. *    event, the IntuiMessage->Code value will hold the ANSI key
  110. *    code of the key the user pressed.
  111. *
  112. *    Do not call this routine before you have actually
  113. *    replied the IntuiMessage received or weird things
  114. *    may happen. This is not a suggestion, it's a threat.
  115. *
  116. ******************************************************************************
  117. *
  118. */
  119.  
  120. VOID LIBENT
  121. LT_HandleInput(REG(a0) LayoutHandle *Handle,REG(d0) ULONG MsgQualifier,REG(a1) ULONG *MsgClass,REG(a2) UWORD *MsgCode,REG(a3) struct Gadget **MsgGadget)
  122. {
  123.     ObjectNode *Node;
  124.     BOOL Activate;
  125.  
  126.     if(!Handle)
  127.         return;
  128.  
  129.     if(Handle->Failed)
  130.     {
  131.         *MsgClass = IDCMP_CLOSEWINDOW;
  132.  
  133.         if(!Handle->NeedDelay)
  134.             Handle->NeedDelay = TRUE;
  135.         else
  136.             LTP_Delay(0,500000);    // Give the guy a break
  137.  
  138.         return;
  139.     }
  140.  
  141.     Activate = FALSE;
  142.  
  143.     switch(*MsgClass)
  144.     {
  145.         case IDCMP_CHANGEWINDOW:
  146.  
  147.             if(!(Handle->Window->Flags & WFLG_SIZEGADGET) && (Handle->Window->Flags & WFLG_HASZOOM) && !V39)
  148.             {
  149.                 #ifdef DO_BOOPSI_KIND
  150.                 {
  151.                     if(Handle->BOOPSIList)
  152.                         RefreshGList((struct Gadget *)Handle->BOOPSIList,Handle->Window,NULL,(UWORD)-1);
  153.                 }
  154.                 #endif    /* DO_BOOPSI_KIND */
  155.  
  156.                 RefreshGList(Handle->List,Handle->Window,NULL,(UWORD)-1);
  157.  
  158.                 GT_RefreshWindow(Handle->Window,NULL);
  159.  
  160.                 LTP_DrawGroup(Handle,Handle->TopGroup);
  161.             }
  162.  
  163.             break;
  164.  
  165.         case IDCMP_NEWSIZE:
  166.  
  167.                 // Did the user cancel the resize operation?
  168.  
  169.             if(Handle->SizeVerified && Handle->SizeWidth == Handle->Window->Width && Handle->SizeHeight == Handle->Window->Height)
  170.             {
  171.                 Handle->SizeVerified    = FALSE;
  172.                 Handle->SizeWidth    = 0;
  173.                 Handle->SizeHeight    = 0;
  174.  
  175.                     // Put the gadgets back in
  176.  
  177.                 AddGList(Handle->Window,Handle->List,(UWORD)-1,(UWORD)-1,NULL);
  178.             }
  179.             else
  180.             {
  181.                 struct IBox Box;
  182.  
  183.                 Handle->SizeWidth    = 0;
  184.                 Handle->SizeHeight    = 0;
  185.  
  186.                 Box.Left    = 0;
  187.                 Box.Top        = 0;
  188.                 Box.Width    = Handle->Window->Width;
  189.                 Box.Height    = Handle->Window->Height;
  190.  
  191.                 LT_LockWindow(Handle->Window);
  192.  
  193.                 if((Handle->ResizeObject != NULL) && (Handle->ResizeObject->Type == LISTVIEW_KIND))
  194.                     Handle->ResizeObject->Special.List.IgnoreListContents = TRUE;
  195.  
  196.                 LT_RebuildTags(Handle,TRUE,
  197.                     LAWN_Bounds,    &Box,
  198.                 TAG_DONE);
  199.  
  200.                 LT_UnlockWindow(Handle->Window);
  201.  
  202.                 if(Handle->Failed)
  203.                     *MsgClass = IDCMP_CLOSEWINDOW;
  204.                 else
  205.                     *MsgClass = NULL;
  206.             }
  207.  
  208.             break;
  209.  
  210.         case IDCMP_REFRESHWINDOW:
  211.  
  212.             if(Handle->AutoRefresh)
  213.             {
  214.                 LT_BeginRefresh(Handle);
  215.  
  216.                 LT_EndRefresh(Handle,TRUE);
  217.  
  218.                 *MsgClass = NULL;
  219.             }
  220.  
  221.             break;
  222.  
  223.         case IDCMP_INTUITICKS:
  224.  
  225.             if(Handle->ActiveIncrementer)
  226.             {
  227.                 if(Handle->IncrementerCountdown > 0)
  228.                     Handle->IncrementerCountdown--;
  229.  
  230.                 if(Handle->IncrementerCountdown <= 0)
  231.                 {
  232.                     if(Handle->ActiveIncrementer->Host->Flags & GFLG_SELECTED)
  233.                     {
  234.                         if(Handle->ActiveIncrementer->Type == TAPEDECK_KIND)
  235.                         {
  236.                             *MsgClass    = IDCMP_GADGETUP;
  237.                             *MsgCode    = 0;
  238.                             *MsgGadget    = Handle->ActiveIncrementer->Host;
  239.                         }
  240.                         else
  241.                         {
  242.                             ObjectNode *Parent;
  243.                             LONG Number;
  244.  
  245.                             if(Handle->IncrementerAccelerate > 0 && !(MsgQualifier & (IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT)))
  246.                                 Handle->IncrementerAccelerate--;
  247.  
  248.                             if(Handle->IncrementerAccelerate <= 0)
  249.                             {
  250.                                 Handle->IncrementerAccelerate = 10;
  251.  
  252.                                 Handle->IncrementerIncrement *= 2;
  253.                             }
  254.  
  255.                             *MsgClass    = IDCMP_GADGETUP;
  256.                             *MsgCode    = 0;
  257.                             *MsgGadget    = Handle->ActiveIncrementer->Special.Incrementer.Parent;
  258.  
  259.                             Parent = (*MsgGadget)->UserData;
  260.  
  261.                             if(Parent->Type == FRACTION_KIND)
  262.                             {
  263.                                 STRPTR String;
  264.  
  265.                                 String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
  266.  
  267.                                 if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,Handle->ActiveIncrementer->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
  268.                                 {
  269.                                     LT_SetAttributes(Handle,Parent->ID,
  270.                                         GTST_String,String,
  271.                                     TAG_DONE);
  272.                                 }
  273.                             }
  274.                             else
  275.                             {
  276.                                 if(Parent->Special.Integer.IncrementerHook)
  277.                                     Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),Handle->ActiveIncrementer->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  278.                                 else
  279.                                     Number = ((LONG)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE)) + Handle->ActiveIncrementer->Special.Incrementer.Amount * Handle->IncrementerIncrement;
  280.  
  281.                                 if(Number < Parent->Min)
  282.                                     Number = Parent->Min;
  283.                                 else
  284.                                 {
  285.                                     if(Number > Parent->Max)
  286.                                         Number = Parent->Max;
  287.                                 }
  288.  
  289.                                 LT_SetAttributes(Handle,Parent->ID,
  290.                                     LAPR_Object,    Parent,
  291.                                     GTIN_Number,    Number,
  292.                                 TAG_DONE);
  293.                             }
  294.                         }
  295.                     }
  296.                     else
  297.                     {
  298.                         Handle->IncrementerIncrement    = 1;
  299.                         Handle->IncrementerAccelerate    = 10;
  300.                     }
  301.  
  302.                     if(Handle->IncrementerIncrement == 1)
  303.                         Handle->IncrementerCountdown = 2;
  304.                 }
  305.             }
  306.  
  307.             break;
  308.  
  309.         case IDCMP_RAWKEY:
  310.         {
  311.             UBYTE Buffer[10];
  312.             LONG Key;
  313.             struct InputEvent event;
  314.             BOOL KeyUp;
  315.  
  316.             if((*MsgCode & ~IECODE_UP_PREFIX) == 95 && Handle->HelpHook)
  317.             {
  318.                 if(!(*MsgCode & IECODE_UP_PREFIX))
  319.                 {
  320.                     ObjectNode *Item;
  321.                     struct HelpMsg Message;
  322.                     struct IBox Box;
  323.  
  324.                     Item = LTP_FindNode_Position(Handle->TopGroup,Handle->Window->MouseX,Handle->Window->MouseY);
  325.  
  326.                     if(Item == Handle->TopGroup)
  327.                     {
  328.                         if(Item->ID <= PHANTOM_GROUP_ID)
  329.                             Item = NULL;
  330.                     }
  331.  
  332.                     if(Item)
  333.                     {
  334.                         Message.ObjectID = Item->ID;
  335.  
  336.                         Box.Left    = Item->Left;
  337.                         Box.Top        = Item->Top;
  338.                         Box.Width    = Item->Width;
  339.                         Box.Height    = Item->Height;
  340.                     }
  341.                     else
  342.                     {
  343.                         Message.ObjectID = -1;
  344.  
  345.                         Box.Left    = 0;
  346.                         Box.Top        = 0;
  347.                         Box.Width    = Handle->Window->Width;
  348.                         Box.Height    = Handle->Window->Height;
  349.                     }
  350.  
  351.                     Message.Handle = Handle;
  352.  
  353.                     CallHookPkt(Handle->HelpHook,&Message,&Box);
  354.                 }
  355.  
  356.                 if(Handle->RawKeyFilter)
  357.                     *MsgClass = NULL;
  358.  
  359.                 break;
  360.             }
  361.  
  362.             if((*MsgCode >= 99 && *MsgCode <= 103) || *MsgCode == 96 || *MsgCode == 97)
  363.             {
  364.                 if(Handle->RawKeyFilter)
  365.                     *MsgClass = NULL;
  366.  
  367.                 break;
  368.             }
  369.  
  370.             event.ie_NextEvent            = NULL;
  371.             event.ie_Code                 = (*MsgCode) & ~IECODE_UP_PREFIX;
  372.             event.ie_Qualifier            = MsgQualifier & ~QUALIFIER_SHIFT;
  373.             event.ie_Class                = IECLASS_RAWKEY;
  374.             event.ie_SubClass            = 0;
  375.             event.ie_position.ie_addr    = (APTR)*MsgGadget;
  376.  
  377.             Buffer[0] = 0;
  378.  
  379.             if(MapRawKey(&event,Buffer,9,NULL) < 1)
  380.             {
  381.                 if(Handle->RawKeyFilter)
  382.                     *MsgClass = NULL;
  383.  
  384.                 break;
  385.             }
  386.  
  387.             if(!(Key = Buffer[0]))
  388.             {
  389.                 if(Handle->RawKeyFilter)
  390.                     *MsgClass = NULL;
  391.  
  392.                 break;
  393.             }
  394.  
  395.             if((*MsgCode) & IECODE_UP_PREFIX)
  396.                 KeyUp = TRUE;
  397.             else
  398.                 KeyUp = FALSE;
  399.  
  400.             if(!KeyUp && Handle->CursorKey && (*MsgCode == CURSORUP || *MsgCode == CURSORDOWN))
  401.             {
  402.                 ObjectNode *Node;
  403.                 struct Gadget *Gadget;
  404.                 LONG NewState;
  405.                 LONG CurrentTop = 0;    /* For the sake of the compiler, initialize this */
  406.  
  407.                 Handle->ClickSeconds = Handle->ClickMicros = 0;
  408.  
  409.                 Node        = Handle->CursorKey;
  410.                 Gadget        = Node->Host;
  411.                 NewState    = Node->Current;
  412.  
  413.                 if(V39)
  414.                 {
  415.                     GT_GetGadgetAttrs(Gadget,Handle->Window,NULL,
  416.                         GTLV_Top,&CurrentTop,
  417.                     TAG_DONE);
  418.                 }
  419.  
  420.                 if(*MsgCode == CURSORDOWN)
  421.                 {
  422.                     if(MsgQualifier & QUALIFIER_SHIFT)
  423.                     {
  424.                         if(V39)
  425.                         {
  426.                             if(NewState != CurrentTop + Node->Lines - 1)
  427.                                 NewState = CurrentTop + Node->Lines - 1;
  428.                             else
  429.                                 NewState += Node->Lines;
  430.                         }
  431.                         else
  432.                             NewState += Node->Lines;
  433.                     }
  434.                     else
  435.                     {
  436.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  437.                             NewState = Node->Max;
  438.                         else
  439.                             NewState++;
  440.                     }
  441.                 }
  442.                 else
  443.                 {
  444.                     if(MsgQualifier & QUALIFIER_SHIFT)
  445.                     {
  446.                         if(V39)
  447.                         {
  448.                             if(NewState != CurrentTop)
  449.                                 NewState = CurrentTop;
  450.                             else
  451.                                 NewState -= Node->Lines;
  452.                         }
  453.                         else
  454.                             NewState -= Node->Lines;
  455.                     }
  456.                     else
  457.                     {
  458.                         if(MsgQualifier & (QUALIFIER_ALT | QUALIFIER_CONTROL))
  459.                             NewState = Node->Min;
  460.                         else
  461.                             NewState--;
  462.                     }
  463.                 }
  464.  
  465.                 if(NewState < Node->Min)
  466.                     NewState = Node->Min;
  467.                 else
  468.                 {
  469.                     if(NewState > Node->Max)
  470.                         NewState = Node->Max;
  471.                 }
  472.  
  473.                 if(NewState != Node->Current || Node->Max == Node->Min)
  474.                 {
  475.                     ULONG WhichTag;
  476.  
  477.                     if(V39)
  478.                         WhichTag = GTLV_MakeVisible;
  479.                     else
  480.                         WhichTag = GTLV_Top;
  481.  
  482.                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  483.                         WhichTag,    Node->Current = NewState,
  484.                         Node->Special.List.LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node->Current,
  485.                     TAG_DONE);
  486.  
  487.                     LTP_PutStorage(Node);
  488.  
  489.                     *MsgClass    = IDCMP_GADGETUP;
  490.                     *MsgCode    = Node->Current;
  491.                     *MsgGadget    = Gadget;
  492.  
  493.                     if(Node->Special.List.AutoPageID != -1)
  494.                         *MsgClass = NULL;
  495.  
  496.                     if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  497.                         *MsgClass = IDCMP_CLOSEWINDOW;
  498.                 }
  499.                 else
  500.                 {
  501.                     if(Handle->RawKeyFilter)
  502.                         *MsgClass = NULL;
  503.                 }
  504.  
  505.                 Handle->ActiveFrame = NULL;
  506.  
  507.                 return;
  508.             }
  509.  
  510.             if(Key == '\t' && !KeyUp)
  511.             {
  512.                 ObjectNode *Node;
  513.  
  514.                 if(Handle->RawKeyFilter)
  515.                     *MsgClass = NULL;
  516.  
  517.                 if(Node = Handle->TabKey)
  518.                 {
  519.                     if(!(Node->Disabled))
  520.                     {
  521.                         LONG Choice;
  522.  
  523.                         if(MsgQualifier & QUALIFIER_SHIFT)
  524.                             Choice = Node->Current - 1;
  525.                         else
  526.                             Choice = Node->Current + 1;
  527.  
  528.                         Choice = CurrentWrap(Node,Choice);
  529.  
  530.                         if(Choice != Node->Current)
  531.                         {
  532.                             LONG AutoPageID = -1,Type = 0;/* For the sake of the compiler, initialize this */
  533.                             BOOL CanBlink = FALSE;
  534.  
  535.                             *MsgClass = IDCMP_GADGETUP;
  536.  
  537.                             switch(Node->Type)
  538.                             {
  539.                                 case CYCLE_KIND:
  540.  
  541.                                     AutoPageID    = Node->Special.Cycle.AutoPageID;
  542.                                     Type        = GTCY_Active;
  543.                                     CanBlink    = TRUE;
  544.                                     break;
  545.  
  546.                                 #ifdef DO_POPUP_KIND
  547.                                 {
  548.                                     case POPUP_KIND:
  549.  
  550.                                         AutoPageID    = Node->Special.Popup.AutoPageID;
  551.                                         Type        = LAPU_Active;
  552.                                         CanBlink    = TRUE;
  553.                                         break;
  554.                                 }
  555.                                 #endif
  556.  
  557.                                 #ifdef DO_TAB_KIND
  558.                                 {
  559.                                     case TAB_KIND:
  560.  
  561.                                         AutoPageID    = Node->Special.Tab.AutoPageID;
  562.                                         Type        = LATB_Active;
  563.                                         break;
  564.                                 }
  565.                                 #endif
  566.  
  567.                                 case MX_KIND:
  568.  
  569.                                     AutoPageID    = Node->Special.Radio.AutoPageID;
  570.                                     Type        = GTMX_Active;
  571.  
  572.                                     *MsgClass = IDCMP_GADGETDOWN;
  573.  
  574.                                     break;
  575.                             }
  576.  
  577.                             *MsgCode    = (UWORD)Choice;
  578.                             *MsgGadget    = Node->Host;
  579.  
  580.                             if(CanBlink)
  581.                                 LTP_BlinkButton(Handle,*MsgGadget);
  582.  
  583.                             LT_SetAttributes(Handle,Node->ID,
  584.                                 Type,Choice,
  585.                             TAG_DONE);
  586.  
  587.                             if(AutoPageID != -1)
  588.                                 *MsgClass = NULL;
  589.  
  590.                             if(!LTP_NotifyPager(Handle,AutoPageID,Choice))
  591.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  592.                         }
  593.                     }
  594.                 }
  595.  
  596.                 Handle->ActiveFrame = NULL;
  597.  
  598.                 return;
  599.             }
  600.  
  601.             if(Key == '\33' && !KeyUp)
  602.             {
  603.                 ObjectNode *Node;
  604.  
  605.                 Handle->ClickSeconds = Handle->ClickMicros = 0;
  606.  
  607.                 if(Node = Handle->EscKey)
  608.                 {
  609.                     if(!Node->Disabled)
  610.                     {
  611.                         LTP_BlinkButton(Handle,Node->Host);
  612.  
  613.                         *MsgCode    = 0;
  614.                         *MsgGadget    = Node->Host;
  615.                         *MsgClass    = IDCMP_GADGETUP;
  616.                     }
  617.                     else
  618.                     {
  619.                         if(Handle->RawKeyFilter)
  620.                             *MsgClass = NULL;
  621.                     }
  622.                 }
  623.                 else
  624.                 {
  625.                     if(Handle->Window->Flags & WFLG_CLOSEGADGET)
  626.                     {
  627.                         *MsgCode    = 0;
  628.                         *MsgGadget    = NULL;
  629.                         *MsgClass    = IDCMP_CLOSEWINDOW;
  630.                     }
  631.                     else
  632.                     {
  633.                         if(Handle->RawKeyFilter)
  634.                             *MsgClass = NULL;
  635.                     }
  636.                 }
  637.  
  638.                 Handle->ActiveFrame = NULL;
  639.  
  640.                 return;
  641.             }
  642.             else
  643.             {
  644.                 struct Gadget *Gadget;
  645.                 ObjectNode *Node;
  646.                 BOOL FoundIt,Forward,Swallow;
  647.                 LONG NewValue;
  648.                 LONG i;
  649.  
  650.                 if(Handle->ReturnKey && Key == '\r')
  651.                 {
  652.                     Node = Handle->ReturnKey;
  653.  
  654.                     if(!KeyUp && !Node->Disabled)
  655.                     {
  656.                         LTP_BlinkButton(Handle,Node->Host);
  657.  
  658.                         *MsgClass    = IDCMP_GADGETUP;
  659.                         *MsgCode    = 0;
  660.                         *MsgGadget    = Node->Host;
  661.                     }
  662.                     else
  663.                     {
  664.                         if(Handle->RawKeyFilter)
  665.                             *MsgClass = NULL;
  666.                     }
  667.  
  668.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  669.  
  670.                     Handle->ActiveFrame = NULL;
  671.  
  672.                     return;
  673.                 }
  674.  
  675.                 if(MsgQualifier & QUALIFIER_SHIFT)
  676.                     Forward = FALSE;
  677.                 else
  678.                     Forward = TRUE;
  679.  
  680.                 FoundIt = FALSE;
  681.  
  682.                 for(i = 0 ; !FoundIt && i < Handle->Count ; i++)
  683.                 {
  684.                     if(Gadget = Handle->GadgetArray[i])
  685.                     {
  686.                         if(GETOBJECT(Gadget,Node))
  687.                         {
  688.                             if(Key == Node->Key)
  689.                             {
  690.                                 if(Node->Disabled)
  691.                                     break;
  692.                                 else
  693.                                 {
  694.                                     Swallow = FALSE;
  695.  
  696.                                     NewValue = Node->Current;
  697.  
  698.                                     switch(Node->Type)
  699.                                     {
  700.                                         #ifdef DO_BOOPSI_KIND
  701.                                         {
  702.                                             case BOOPSI_KIND:
  703.  
  704.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  705.                                                 {
  706.                                                     if(Node->Special.BOOPSI.ActivateHook)
  707.                                                     {
  708.                                                         if(CallHookPkt(Node->Special.BOOPSI.ActivateHook,(APTR)Handle,(APTR)Node->Host))
  709.                                                         {
  710.                                                             Swallow = TRUE;
  711.                                                             break;
  712.                                                         }
  713.                                                     }
  714.  
  715.                                                     *MsgClass    = IDCMP_GADGETUP;
  716.                                                     *MsgCode    = Forward ? 1 : (UWORD)-1;
  717.                                                     *MsgGadget    = Gadget;
  718.                                                 }
  719.                                                 else
  720.                                                     Swallow = TRUE;
  721.  
  722.                                                 break;
  723.                                         }
  724.                                         #endif    /* DO_BOOPSI_KIND */
  725.  
  726.                                         #ifdef DO_POPUP_KIND
  727.                                         {
  728.                                             case POPUP_KIND:
  729.  
  730.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  731.                                                 {
  732.                                                     if(Forward)
  733.                                                         NewValue++;
  734.                                                     else
  735.                                                         NewValue--;
  736.  
  737.                                                     NewValue = CurrentWrap(Node,NewValue);
  738.  
  739.                                                     LTP_BlinkButton(Handle,Node->Host);
  740.  
  741.                                                     LT_SetAttributes(Handle,0,
  742.                                                         LAPR_Gadget,    Node->Host,
  743.                                                         LAPU_Active,    NewValue,
  744.                                                     TAG_DONE);
  745.  
  746.                                                     *MsgClass    = IDCMP_GADGETUP;
  747.                                                     *MsgCode    = Node->Current;
  748.                                                     *MsgGadget    = Node->Host;
  749.                                                 }
  750.                                                 else
  751.                                                     Swallow = TRUE;
  752.  
  753.                                                 break;
  754.                                         }
  755.                                         #endif    // DO_POPUP_KIND
  756.  
  757.                                         #ifdef DO_TAB_KIND
  758.                                         {
  759.                                             case TAB_KIND:
  760.  
  761.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  762.                                                 {
  763.                                                     if(Forward)
  764.                                                         NewValue++;
  765.                                                     else
  766.                                                         NewValue--;
  767.  
  768.                                                     NewValue = CurrentWrap(Node,NewValue);
  769.  
  770.                                                     LT_SetAttributes(Handle,0,
  771.                                                         LAPR_Gadget,    Node->Host,
  772.                                                         LAPU_Active,    NewValue,
  773.                                                     TAG_DONE);
  774.  
  775.                                                     *MsgClass    = IDCMP_GADGETUP;
  776.                                                     *MsgCode    = Node->Current;
  777.                                                     *MsgGadget    = Node->Host;
  778.                                                 }
  779.                                                 else
  780.                                                     Swallow = TRUE;
  781.  
  782.                                                 break;
  783.                                         }
  784.                                         #endif    // DO_TAB_KIND
  785.  
  786.                                         #ifdef DO_TAPEDECK_KIND
  787.                                         {
  788.                                             case TAPEDECK_KIND:
  789.  
  790.                                                 if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  791.                                                 {
  792.                                                     if(Node->Special.TapeDeck.Toggle)
  793.                                                     {
  794.                                                         LT_SetAttributes(Handle,Node->ID,
  795.                                                             LAPR_Object,    Node,
  796.                                                             LATD_Pressed,    !Node->Current,
  797.                                                         TAG_DONE);
  798.                                                     }
  799.                                                     else
  800.                                                         LTP_BlinkButton(Handle,Gadget);
  801.  
  802.                                                     if(Gadget->Flags & GFLG_SELECTED)
  803.                                                         *MsgCode = TRUE;
  804.                                                     else
  805.                                                         *MsgCode = FALSE;
  806.  
  807.                                                     *MsgClass    = IDCMP_GADGETUP;
  808.                                                     *MsgGadget    = Gadget;
  809.                                                 }
  810.                                                 else
  811.                                                     Swallow = TRUE;
  812.  
  813.                                                 break;
  814.                                         }
  815.                                         #endif    /* DO_TAPEDECK_KIND */
  816.  
  817.                                         case CHECKBOX_KIND:
  818.  
  819.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  820.                                             {
  821.                                                 Node->Current = !Node->Current;
  822.  
  823.                                                 LTP_PutStorage(Node);
  824.  
  825.                                                 GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  826.                                                     GTCB_Checked,Node->Current,
  827.                                                 TAG_DONE);
  828.  
  829.                                                 *MsgClass    = IDCMP_GADGETUP;
  830.                                                 *MsgCode    = Node->Current;
  831.                                                 *MsgGadget    = Gadget;
  832.                                             }
  833.                                             else
  834.                                                 Swallow = TRUE;
  835.  
  836.                                             FoundIt = TRUE;
  837.  
  838.                                             break;
  839.  
  840.                                         case LISTVIEW_KIND:
  841.  
  842.                                             if(!KeyUp)
  843.                                             {
  844.                                                 if(NewValue == -1)
  845.                                                 {
  846.                                                     if(Node->Min != -1)
  847.                                                     {
  848.                                                         if(Forward)
  849.                                                             NewValue = Node->Min;
  850.                                                         else
  851.                                                             NewValue = Node->Max;
  852.                                                     }
  853.                                                 }
  854.                                                 else
  855.                                                 {
  856.                                                     if(Forward)
  857.                                                         NewValue++;
  858.                                                     else
  859.                                                         NewValue--;
  860.                                                 }
  861.  
  862.                                                 if(CurrentInBounds(Node,NewValue))
  863.                                                 {
  864.                                                     ULONG WhichTag;
  865.  
  866.                                                     if(V39)
  867.                                                         WhichTag = GTLV_MakeVisible;
  868.                                                     else
  869.                                                         WhichTag = GTLV_Top;
  870.  
  871.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  872.                                                         WhichTag,Node->Current = NewValue,
  873.                                                         Node->Special.List.LinkID != -1 ? GTLV_Selected : TAG_IGNORE,Node->Current,
  874.                                                     TAG_DONE);
  875.  
  876.                                                     LTP_PutStorage(Node);
  877.  
  878.                                                     *MsgClass    = IDCMP_GADGETUP;
  879.                                                     *MsgCode    = Node->Current;
  880.                                                     *MsgGadget    = Gadget;
  881.  
  882.                                                     if(Node->Special.List.AutoPageID != -1)
  883.                                                     {
  884.                                                         *MsgClass = NULL;
  885.  
  886.                                                         if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  887.                                                             *MsgClass = IDCMP_CLOSEWINDOW;
  888.                                                     }
  889.                                                 }
  890.                                                 else
  891.                                                     Swallow = TRUE;
  892.                                             }
  893.                                             else
  894.                                                 Swallow = TRUE;
  895.  
  896.                                             FoundIt = TRUE;
  897.  
  898.                                             break;
  899.  
  900.                                         case MX_KIND:
  901.  
  902.                                             if(!KeyUp)
  903.                                             {
  904.                                                 if(Forward)
  905.                                                     NewValue++;
  906.                                                 else
  907.                                                     NewValue--;
  908.  
  909.                                                 if(CurrentInBounds(Node,NewValue))
  910.                                                 {
  911.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  912.                                                         GTMX_Active,Node->Current = NewValue,
  913.                                                     TAG_DONE);
  914.  
  915.                                                     LTP_PutStorage(Node);
  916.  
  917.                                                     *MsgClass    = IDCMP_GADGETDOWN;
  918.                                                     *MsgCode    = Node->Current;
  919.                                                     *MsgGadget    = Gadget;
  920.  
  921.                                                     if(Node->Special.Radio.AutoPageID != -1)
  922.                                                     {
  923.                                                         *MsgClass = NULL;
  924.  
  925.                                                         if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  926.                                                             *MsgClass = IDCMP_CLOSEWINDOW;
  927.                                                     }
  928.                                                 }
  929.                                                 else
  930.                                                     Swallow = TRUE;
  931.                                             }
  932.                                             else
  933.                                                 Swallow = TRUE;
  934.  
  935.                                             FoundIt = TRUE;
  936.  
  937.                                             break;
  938.  
  939.                                         case TEXT_KIND:
  940.  
  941.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  942.                                             {
  943.                                                 if(Node->Special.Text.Picker)
  944.                                                 {
  945.                                                     LTP_BlinkButton(Handle,Node->Special.Text.Picker);
  946.  
  947.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  948.                                                     *MsgCode    = 0;
  949.                                                     *MsgGadget    = Gadget;
  950.                                                 }
  951.                                                 else
  952.                                                     Swallow = TRUE;
  953.                                             }
  954.                                             else
  955.                                                 Swallow = TRUE;
  956.  
  957.                                             FoundIt = TRUE;
  958.  
  959.                                             break;
  960.  
  961.                                         case NUMBER_KIND:
  962.  
  963.                                             Swallow = TRUE;
  964.                                             FoundIt = TRUE;
  965.  
  966.                                             break;
  967.  
  968.                                         case CYCLE_KIND:
  969.  
  970.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  971.                                             {
  972.                                                 if(Forward)
  973.                                                     NewValue++;
  974.                                                 else
  975.                                                     NewValue--;
  976.  
  977.                                                 NewValue = CurrentWrap(Node,NewValue);
  978.  
  979.                                                 LTP_BlinkButton(Handle,Gadget);
  980.  
  981.                                                 GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  982.                                                     GTCY_Active,Node->Current = NewValue,
  983.                                                 TAG_DONE);
  984.  
  985.                                                 LTP_PutStorage(Node);
  986.  
  987.                                                 *MsgClass    = IDCMP_GADGETUP;
  988.                                                 *MsgCode    = Node->Current;
  989.                                                 *MsgGadget    = Gadget;
  990.  
  991.                                                 if(Node->Special.Cycle.AutoPageID != -1)
  992.                                                 {
  993.                                                     *MsgClass = NULL;
  994.  
  995.                                                     if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  996.                                                         *MsgClass = IDCMP_CLOSEWINDOW;
  997.                                                 }
  998.                                             }
  999.                                             else
  1000.                                                 Swallow = TRUE;
  1001.  
  1002.                                             FoundIt = TRUE;
  1003.  
  1004.                                             break;
  1005.  
  1006.                                         case PALETTE_KIND:
  1007.  
  1008.                                             if(!KeyUp)
  1009.                                             {
  1010.                                                 if(Node->Special.Palette.UsePicker)
  1011.                                                 {
  1012.                                                     if(!(MsgQualifier & IEQUALIFIER_REPEAT))
  1013.                                                     {
  1014.                                                         LTP_BlinkButton(Handle,Node->Special.Palette.Picker);
  1015.  
  1016.                                                         *MsgClass    = IDCMP_IDCMPUPDATE;
  1017.                                                         *MsgCode    = 0;
  1018.                                                         *MsgGadget    = Gadget;
  1019.                                                     }
  1020.                                                     else
  1021.                                                         Swallow = TRUE;
  1022.  
  1023.                                                     FoundIt = TRUE;
  1024.  
  1025.                                                     break;
  1026.                                                 }
  1027.  
  1028.                                                 if(Node->Special.Palette.TranslateBack)
  1029.                                                 {
  1030.                                                     LONG Index = Node->Special.Palette.TranslateBack[Node->Current];
  1031.  
  1032.                                                     if(Index < Node->Min)
  1033.                                                         Index = Node->Min;
  1034.                                                     else
  1035.                                                     {
  1036.                                                         if(Index > Node->Max)
  1037.                                                             Index = Node->Max;
  1038.                                                     }
  1039.  
  1040.                                                     if(Forward)
  1041.                                                         Index++;
  1042.                                                     else
  1043.                                                         Index--;
  1044.  
  1045.                                                     if(Index < Node->Min)
  1046.                                                         Index = Node->Min;
  1047.                                                     else
  1048.                                                     {
  1049.                                                         if(Index > Node->Max)
  1050.                                                             Index = Node->Max;
  1051.                                                     }
  1052.  
  1053.                                                     NewValue = Node->Special.Palette.ColourTable[Index];
  1054.                                                 }
  1055.                                                 else
  1056.                                                 {
  1057.                                                     if(Forward)
  1058.                                                         NewValue++;
  1059.                                                     else
  1060.                                                         NewValue--;
  1061.                                                 }
  1062.  
  1063.                                                 if(CurrentInBounds(Node,NewValue))
  1064.                                                 {
  1065.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  1066.                                                         GTPA_Color,Node->Current = NewValue,
  1067.                                                     TAG_DONE);
  1068.  
  1069.                                                     LTP_PutStorage(Node);
  1070.  
  1071.                                                     *MsgClass    = IDCMP_GADGETUP;
  1072.                                                     *MsgCode    = Node->Current;
  1073.                                                     *MsgGadget    = Gadget;
  1074.                                                 }
  1075.                                                 else
  1076.                                                     Swallow = TRUE;
  1077.                                             }
  1078.                                             else
  1079.                                                 Swallow = TRUE;
  1080.  
  1081.                                             FoundIt = TRUE;
  1082.  
  1083.                                             break;
  1084.  
  1085.                                         case SLIDER_KIND:
  1086.  
  1087.                                             if(KeyUp)
  1088.                                             {
  1089.                                                 *MsgClass    = IDCMP_GADGETUP;
  1090.                                                 *MsgCode    = Node->Current;
  1091.                                                 *MsgGadget    = Gadget;
  1092.                                             }
  1093.                                             else
  1094.                                             {
  1095.                                                 if(Forward)
  1096.                                                     NewValue++;
  1097.                                                 else
  1098.                                                     NewValue--;
  1099.  
  1100.                                                 if(CurrentInBounds(Node,NewValue))
  1101.                                                 {
  1102.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  1103.                                                         GTSL_Level,Node->Current = NewValue,
  1104.                                                     TAG_DONE);
  1105.  
  1106.                                                     LTP_PutStorage(Node);
  1107.  
  1108.                                                     *MsgClass    = IDCMP_MOUSEMOVE;
  1109.                                                     *MsgCode    = Node->Current;
  1110.                                                     *MsgGadget    = Gadget;
  1111.                                                 }
  1112.                                                 else
  1113.                                                     Swallow = TRUE;
  1114.                                             }
  1115.  
  1116.                                             FoundIt = TRUE;
  1117.  
  1118.                                             break;
  1119.  
  1120.                                         #ifdef DO_LEVEL_KIND
  1121.                                         {
  1122.                                             case LEVEL_KIND:
  1123.  
  1124.                                                 if(KeyUp)
  1125.                                                 {
  1126.                                                     *MsgClass    = IDCMP_GADGETUP;
  1127.                                                     *MsgCode    = Node->Current;
  1128.                                                     *MsgGadget    = Gadget;
  1129.  
  1130.                                                     LTP_PutStorage(Node);
  1131.  
  1132.                                                     LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1133.                                                 }
  1134.                                                 else
  1135.                                                 {
  1136.                                                     if(Forward)
  1137.                                                         NewValue++;
  1138.                                                     else
  1139.                                                         NewValue--;
  1140.  
  1141.                                                     if(CurrentInBounds(Node,NewValue))
  1142.                                                     {
  1143.                                                         LT_SetAttributes(Handle,Node->ID,
  1144.                                                             LAPR_Object,    Node,
  1145.                                                             LAVL_Level,        NewValue,
  1146.                                                         TAG_DONE);
  1147.  
  1148.                                                         *MsgClass    = IDCMP_MOUSEMOVE;
  1149.                                                         *MsgCode    = NewValue;
  1150.                                                         *MsgGadget    = Gadget;
  1151.  
  1152.                                                         LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1153.                                                     }
  1154.                                                     else
  1155.                                                         Swallow = TRUE;
  1156.                                                 }
  1157.  
  1158.                                                 FoundIt = TRUE;
  1159.  
  1160.                                                 break;
  1161.                                         }
  1162.                                         #endif    /* DO_LEVEL_KIND */
  1163.  
  1164.                                         case SCROLLER_KIND:
  1165.  
  1166.                                             if(KeyUp)
  1167.                                             {
  1168.                                                 *MsgClass    = IDCMP_GADGETUP;
  1169.                                                 *MsgCode    = Node->Current;
  1170.                                                 *MsgGadget    = Gadget;
  1171.                                             }
  1172.                                             else
  1173.                                             {
  1174.                                                 if(Forward)
  1175.                                                     NewValue++;
  1176.                                                 else
  1177.                                                     NewValue--;
  1178.  
  1179.                                                 if(CurrentInBounds(Node,NewValue))
  1180.                                                 {
  1181.                                                     GT_SetGadgetAttrs(Gadget,Handle->Window,NULL,
  1182.                                                         GTSC_Top,Node->Current = NewValue,
  1183.                                                     TAG_DONE);
  1184.  
  1185.                                                     LTP_PutStorage(Node);
  1186.  
  1187.                                                     *MsgClass    = IDCMP_MOUSEMOVE;
  1188.                                                     *MsgCode    = Node->Current;
  1189.                                                     *MsgGadget    = Gadget;
  1190.                                                 }
  1191.                                                 else
  1192.                                                     Swallow = TRUE;
  1193.                                             }
  1194.  
  1195.                                             FoundIt = TRUE;
  1196.  
  1197.                                             break;
  1198.  
  1199.                                         case STRING_KIND:
  1200.                                         case PASSWORD_KIND:
  1201.  
  1202.                                             if(!KeyUp)
  1203.                                             {
  1204.                                                 if(Node->Special.String.Picker && !Forward)
  1205.                                                 {
  1206.                                                     LTP_BlinkButton(Handle,Node->Special.String.Picker);
  1207.  
  1208.                                                     *MsgClass    = IDCMP_IDCMPUPDATE;
  1209.                                                     *MsgCode    = 0;
  1210.                                                     *MsgGadget    = Gadget;
  1211.                                                 }
  1212.                                                 else
  1213.                                                 {
  1214.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1215.  
  1216.                                                     *MsgClass    = IDCMP_GADGETDOWN;
  1217.                                                     *MsgCode    = 0;
  1218.                                                     *MsgGadget    = Gadget;
  1219.  
  1220.                                                     Handle->Previous = Gadget;
  1221.                                                 }
  1222.                                             }
  1223.                                             else
  1224.                                                 Swallow = TRUE;
  1225.  
  1226.                                             FoundIt = TRUE;
  1227.  
  1228.                                             break;
  1229.  
  1230.                                         case FRACTION_KIND:
  1231.  
  1232.                                             if(!KeyUp)
  1233.                                             {
  1234.                                                 if(Node->Special.String.IncrementerHook)
  1235.                                                 {
  1236.                                                     ObjectNode *incNode,*Parent;
  1237.                                                     struct Gadget *Incrementer;
  1238.                                                     STRPTR String;
  1239.  
  1240.                                                     Parent = (ObjectNode *)Gadget->UserData;
  1241.  
  1242.                                                     if(Forward)
  1243.                                                     {
  1244.                                                         incNode = Node->Special.String.RightIncrementer->UserData;
  1245.  
  1246.                                                         Incrementer = Node->Special.String.RightIncrementer;
  1247.                                                     }
  1248.                                                     else
  1249.                                                     {
  1250.                                                         incNode = Node->Special.String.LeftIncrementer->UserData;
  1251.  
  1252.                                                         Incrementer = Node->Special.String.LeftIncrementer;
  1253.                                                     }
  1254.  
  1255.                                                     String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
  1256.  
  1257.                                                     if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,incNode->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
  1258.                                                     {
  1259.                                                         LTP_BlinkButton(Handle,Incrementer);
  1260.  
  1261.                                                         LT_SetAttributes(Handle,Parent->ID,
  1262.                                                             GTST_String,String,
  1263.                                                         TAG_DONE);
  1264.  
  1265.                                                         *MsgClass = IDCMP_GADGETUP;
  1266.                                                     }
  1267.                                                 }
  1268.                                                 else
  1269.                                                 {
  1270.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1271.  
  1272.                                                     *MsgClass = IDCMP_GADGETDOWN;
  1273.                                                 }
  1274.  
  1275.                                                 *MsgCode    = 0;
  1276.                                                 *MsgGadget    = Gadget;
  1277.  
  1278.                                                 Handle->Previous = Gadget;
  1279.                                             }
  1280.                                             else
  1281.                                                 Swallow = TRUE;
  1282.  
  1283.                                             FoundIt = TRUE;
  1284.  
  1285.                                             break;
  1286.  
  1287.                                         case INTEGER_KIND:
  1288.  
  1289.                                             if(!KeyUp)
  1290.                                             {
  1291.                                                 if(Node->Special.Integer.UseIncrementers)
  1292.                                                 {
  1293.                                                     ObjectNode *incNode,*Parent;
  1294.                                                     struct Gadget *Incrementer;
  1295.                                                     LONG Number;
  1296.  
  1297.                                                     Parent = (ObjectNode *)Gadget->UserData;
  1298.  
  1299.                                                     if(Forward)
  1300.                                                     {
  1301.                                                         incNode = Node->Special.Integer.RightIncrementer->UserData;
  1302.  
  1303.                                                         Incrementer = Node->Special.Integer.RightIncrementer;
  1304.                                                     }
  1305.                                                     else
  1306.                                                     {
  1307.                                                         incNode = Node->Special.Integer.LeftIncrementer->UserData;
  1308.  
  1309.                                                         Incrementer = Node->Special.Integer.LeftIncrementer;
  1310.                                                     }
  1311.  
  1312.                                                     if(Parent->Special.Integer.IncrementerHook)
  1313.                                                         Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),incNode->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1314.                                                     else
  1315.                                                         Number = ((LONG)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE)) + incNode->Special.Incrementer.Amount;
  1316.  
  1317.                                                     if(Node->Min <= Number && Number <= Node->Max && Number != Parent->Special.Integer.Number)
  1318.                                                     {
  1319.                                                         LTP_BlinkButton(Handle,Incrementer);
  1320.  
  1321.                                                         LT_SetAttributes(Handle,Parent->ID,
  1322.                                                             LAPR_Object,    Parent,
  1323.                                                             GTIN_Number,    Number,
  1324.                                                         TAG_DONE);
  1325.  
  1326.                                                         *MsgClass = IDCMP_GADGETUP;
  1327.                                                     }
  1328.                                                 }
  1329.                                                 else
  1330.                                                 {
  1331.                                                     ActivateGadget(Gadget,Handle->Window,NULL);
  1332.  
  1333.                                                     *MsgClass = IDCMP_GADGETDOWN;
  1334.                                                 }
  1335.  
  1336.                                                 *MsgCode    = 0;
  1337.                                                 *MsgGadget    = Gadget;
  1338.  
  1339.                                                 Handle->Previous = Gadget;
  1340.                                             }
  1341.                                             else
  1342.                                                 Swallow = TRUE;
  1343.  
  1344.                                             FoundIt = TRUE;
  1345.  
  1346.                                             break;
  1347.  
  1348.                                         case BUTTON_KIND:
  1349.  
  1350.                                             if(!KeyUp && !(MsgQualifier & IEQUALIFIER_REPEAT))
  1351.                                             {
  1352.                                                 LTP_BlinkButton(Handle,Gadget);
  1353.  
  1354.                                                 *MsgClass    = IDCMP_GADGETUP;
  1355.                                                 *MsgCode    = 0;
  1356.                                                 *MsgGadget    = Gadget;
  1357.                                             }
  1358.                                             else
  1359.                                                 Swallow = TRUE;
  1360.  
  1361.                                             FoundIt = TRUE;
  1362.  
  1363.                                             break;
  1364.                                     }
  1365.  
  1366.                                     if(Swallow)
  1367.                                     {
  1368.                                         if(Handle->RawKeyFilter)
  1369.                                             *MsgClass = NULL;
  1370.                                     }
  1371.                                 }
  1372.                             }
  1373.                         }
  1374.                     }
  1375.                 }
  1376.  
  1377.                 if(FoundIt)
  1378.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  1379.             }
  1380.  
  1381.             Handle->ActiveFrame = NULL;
  1382.  
  1383.             break;
  1384.         }
  1385.  
  1386.         case IDCMP_GADGETDOWN:
  1387.  
  1388.             if(GETOBJECT((*MsgGadget),Node))
  1389.             {
  1390.                 if(Node->Type != LISTVIEW_KIND)
  1391.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  1392.  
  1393.                 Handle->ActiveFrame = NULL;
  1394.  
  1395.                 switch(Node->Type)
  1396.                 {
  1397.                     #ifdef DO_LEVEL_KIND
  1398.                     {
  1399.                         case LEVEL_KIND:
  1400.  
  1401.                             Handle->CurrentLevel = Node;
  1402.  
  1403.                             Node->Current = LTP_GetCurrentLevel(Node);
  1404.  
  1405.                             *MsgCode = Node->Current;
  1406.  
  1407.                             LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1408.  
  1409.                             break;
  1410.                     }
  1411.                     #endif    /* DO_LEVEL_KIND */
  1412.  
  1413.                     case STRING_KIND:
  1414.                     case FRACTION_KIND:
  1415.                     case INTEGER_KIND:
  1416.                     case PASSWORD_KIND:
  1417.  
  1418.                         Handle->Previous = *MsgGadget;
  1419.                         break;
  1420.  
  1421.                     #ifdef DO_TAPEDECK_KIND
  1422.                     {
  1423.                         case TAPEDECK_KIND:
  1424.  
  1425.                             if(Node->Special.TapeDeck.Tick)
  1426.                             {
  1427.                                 Handle->ActiveIncrementer        = Node;
  1428.                                 Handle->IncrementerCountdown    = 2;
  1429.                                 Handle->IncrementerAccelerate    = 10;
  1430.                                 Handle->IncrementerIncrement    = 1;
  1431.  
  1432.                                 *MsgClass    = IDCMP_GADGETUP;
  1433.                                 *MsgCode    = 0;
  1434.                             }
  1435.                             else
  1436.                             {
  1437.                                 if(Node->Special.TapeDeck.Toggle)
  1438.                                 {
  1439.                                     if((*MsgGadget)->Flags & GFLG_SELECTED)
  1440.                                         *MsgCode = TRUE;
  1441.                                     else
  1442.                                         *MsgCode = FALSE;
  1443.  
  1444.                                     Node->Current = *MsgCode;
  1445.  
  1446.                                     LTP_PutStorage(Node);
  1447.  
  1448.                                     if(Handle->Previous && !Node->PageSelector)
  1449.                                         Activate = TRUE;
  1450.  
  1451.                                     *MsgClass = IDCMP_GADGETUP;
  1452.                                 }
  1453.                             }
  1454.  
  1455.                             break;
  1456.                     }
  1457.                     #endif    /* DO_TAPEDECK_KIND */
  1458.  
  1459.                     case MX_KIND:
  1460.  
  1461.                         if(!V39 && Node->Disabled)
  1462.                         {
  1463.                             GT_SetGadgetAttrs(*MsgGadget,Handle->Window,NULL,
  1464.                                 GTMX_Active,Node->Current,
  1465.                             TAG_DONE);
  1466.  
  1467.                             *MsgClass = NULL;
  1468.                         }
  1469.                         else
  1470.                         {
  1471.                             Node->Current = *MsgCode;
  1472.  
  1473.                             LTP_PutStorage(Node);
  1474.  
  1475.                             if(Node->Special.Radio.AutoPageID != -1)
  1476.                             {
  1477.                                 *MsgClass = NULL;
  1478.  
  1479.                                 if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  1480.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1481.                             }
  1482.  
  1483.                             if(Handle->Previous && !Node->PageSelector)
  1484.                                 Activate = TRUE;
  1485.                         }
  1486.  
  1487.                         break;
  1488.  
  1489.                     case SLIDER_KIND:
  1490.  
  1491.                         if(Node->Min < 0)
  1492.                             Node->Current = (WORD)*MsgCode;
  1493.                         else
  1494.                             Node->Current = *MsgCode;
  1495.  
  1496.                         LTP_PutStorage(Node);
  1497.  
  1498.                         if(Handle->Previous && !Node->PageSelector)
  1499.                             Activate = TRUE;
  1500.  
  1501.                         break;
  1502.  
  1503.                     case SCROLLER_KIND:
  1504.  
  1505.                         Node->Current = *MsgCode;
  1506.  
  1507.                         LTP_PutStorage(Node);
  1508.  
  1509.                         if(Handle->Previous && !Node->PageSelector)
  1510.                             Activate = TRUE;
  1511.  
  1512.                         break;
  1513.  
  1514.                     case INCREMENTER_KIND:
  1515.  
  1516.                         Handle->ActiveIncrementer        = Node;
  1517.                         Handle->IncrementerCountdown    = 6;
  1518.                         Handle->IncrementerAccelerate    = 10;
  1519.                         Handle->IncrementerIncrement    = 1;
  1520.  
  1521.                         *MsgClass    = IDCMP_GADGETUP;
  1522.                         *MsgCode    = 0;
  1523.                         *MsgGadget    = Node->Special.Incrementer.Parent;
  1524.  
  1525.                         /* ALWAYS */
  1526.                         {
  1527.                             struct ObjectNode *Parent;
  1528.                             LONG Number;
  1529.  
  1530.                             Parent = (ObjectNode *)(*MsgGadget)->UserData;
  1531.  
  1532.                             if(Parent->Type == FRACTION_KIND)
  1533.                             {
  1534.                                 STRPTR String;
  1535.  
  1536.                                 String = (STRPTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE);
  1537.  
  1538.                                 if(CallHookPkt(Parent->Special.String.IncrementerHook,(APTR)String,Node->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT))
  1539.                                 {
  1540.                                     LT_SetAttributes(Handle,Parent->ID,
  1541.                                         GTST_String,String,
  1542.                                     TAG_DONE);
  1543.                                 }
  1544.                             }
  1545.                             else
  1546.                             {
  1547.                                 if(Parent->Special.Integer.IncrementerHook)
  1548.                                     Number = CallHookPkt(Parent->Special.Integer.IncrementerHook,(APTR)LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE),Node->Special.Incrementer.Amount < 0 ? (APTR)INCREMENTERMSG_DECREMENT : (APTR)INCREMENTERMSG_INCREMENT);
  1549.                                 else
  1550.                                     Number = LT_GetAttributes(Handle,Parent->ID,LAPR_Object,Parent,TAG_DONE) + Node->Special.Incrementer.Amount;
  1551.  
  1552.                                 if(Number >= Parent->Min && Number <= Parent->Max)
  1553.                                     LT_SetAttributes(Handle,Parent->ID,LAPR_Object,Parent,GTIN_Number,Number,TAG_DONE);
  1554.                                 else
  1555.                                     *MsgClass = NULL;
  1556.                             }
  1557.                         }
  1558.  
  1559.                         break;
  1560.                 }
  1561.             }
  1562.  
  1563.             break;
  1564.  
  1565.         case IDCMP_MOUSEBUTTONS:
  1566.         {
  1567.             ObjectNode *Node;
  1568.             LONG x,y;
  1569.  
  1570.             x = Handle->Window->MouseX;
  1571.             y = Handle->Window->MouseY;
  1572.  
  1573.             Node = LTP_FindNode_Position(Handle->TopGroup,x,y);
  1574.  
  1575.             if(((*MsgCode) & IECODE_UP_PREFIX) && Handle->Previous)
  1576.                 Activate = TRUE;
  1577.  
  1578.             if(Node && !Node->Disabled)
  1579.             {
  1580.                 if(*MsgCode == SELECTDOWN)
  1581.                 {
  1582.                     switch(Node->Type)
  1583.                     {
  1584.                         case CHECKBOX_KIND:
  1585.  
  1586.                             Node->Current = !Node->Current;
  1587.  
  1588.                             LTP_PutStorage(Node);
  1589.  
  1590.                             GT_SetGadgetAttrs(Node->Host,Handle->Window,NULL,
  1591.                                 GTCB_Checked,Node->Current,
  1592.                             TAG_DONE);
  1593.  
  1594.                             *MsgClass    = IDCMP_GADGETUP;
  1595.                             *MsgCode    = Node->Current;
  1596.                             *MsgGadget    = Node->Host;
  1597.  
  1598.                             break;
  1599.  
  1600.                         case MX_KIND:
  1601.                         {
  1602.                             LONG Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1603.  
  1604.                             if(Index != -1)
  1605.                             {
  1606.                                 Node->Current = Index;
  1607.  
  1608.                                 GT_SetGadgetAttrs(Node->Host,Handle->Window,NULL,
  1609.                                     GTMX_Active,Index,
  1610.                                 TAG_DONE);
  1611.  
  1612.                                 LTP_PutStorage(Node);
  1613.  
  1614.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1615.                                 *MsgCode    = Index;
  1616.                                 *MsgGadget    = Node->Host;
  1617.  
  1618.                                 if(Node->Special.Cycle.AutoPageID != -1)
  1619.                                     *MsgClass = NULL;
  1620.  
  1621.                                 if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1622.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1623.                             }
  1624.  
  1625.                             break;
  1626.                         }
  1627.  
  1628.                         case FRAME_KIND:
  1629.  
  1630.                             if(Node->Special.Frame.GenerateEvents)
  1631.                             {
  1632.                                 if(Node->Special.Frame.DrawBox)
  1633.                                 {
  1634.                                     if(x < Node->Left + 2 || x >= Node->Left + Node->Width - 2 || y < Node->Top + 1 || y >= Node->Top + Node->Height - 2)
  1635.                                         break;
  1636.                                 }
  1637.  
  1638.                                 *MsgClass    = IDCMP_GADGETDOWN;
  1639.                                 *MsgGadget    = &Node->Special.Frame.Dummy;
  1640.  
  1641.                                 Handle->ActiveFrame = Node;
  1642.                             }
  1643.  
  1644.                             break;
  1645.                     }
  1646.                 }
  1647.  
  1648.                 if(*MsgCode == SELECTUP)
  1649.                 {
  1650.                         // Now this is a real kludge; as of v37 the
  1651.                         // MX_KIND labels are not part of the gadget
  1652.                         // itself and a plain SELECTDOWN mouse event
  1653.                         // is sent as soon as the user clicks on it.
  1654.                         // This changed with v39 which presumably had
  1655.                         // some code in there to map mouse clicks on
  1656.                         // the gadget labels to proper buttonpress
  1657.                         // events. Now, try as you might the click is
  1658.                         // swallowed and we have to do with the
  1659.                         // SELECTUP, sigh...
  1660.  
  1661.                     if(V39 && Node->Type == MX_KIND)
  1662.                     {
  1663.                         LONG Index;
  1664.  
  1665.                         Index = LTP_Find_Clicked_Item(Handle,Node,x,y);
  1666.  
  1667.                         if(Index != -1)
  1668.                         {
  1669.                             GT_SetGadgetAttrs(Node->Host,Handle->Window,NULL,
  1670.                                 GTMX_Active,Index,
  1671.                             TAG_DONE);
  1672.  
  1673.                             Node->Current = Index;
  1674.  
  1675.                             LTP_PutStorage(Node);
  1676.  
  1677.                             *MsgClass    = IDCMP_GADGETDOWN;
  1678.                             *MsgCode    = Index;
  1679.                             *MsgGadget    = Node->Host;
  1680.  
  1681.                             if(Node->Special.Cycle.AutoPageID != -1)
  1682.                                 *MsgClass = NULL;
  1683.  
  1684.                             if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1685.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1686.                         }
  1687.                     }
  1688.  
  1689.                     if(Handle->ActiveIncrementer)
  1690.                     {
  1691.                         if(Handle->ActiveIncrementer->Type == TAPEDECK_KIND && Handle->ActiveIncrementer ->Special.TapeDeck.Tick)
  1692.                         {
  1693.                             Handle->ActiveIncrementer = NULL;
  1694.  
  1695.                             *MsgClass    = IDCMP_GADGETUP;
  1696.                             *MsgCode    = 1;
  1697.                         }
  1698.                         else
  1699.                         {
  1700.                             if(((ObjectNode *)Handle->ActiveIncrementer->Special.Incrementer.Parent->UserData)->Type == INTEGER_KIND)
  1701.                             {
  1702.                                 *MsgGadget    = Handle->ActiveIncrementer->Special.Incrementer.Parent;
  1703.                                 *MsgClass    = IDCMP_GADGETUP;
  1704.                                 *MsgCode    = 1;
  1705.                             }
  1706.  
  1707.                             Handle->ActiveIncrementer = NULL;
  1708.                         }
  1709.                     }
  1710.  
  1711.                     if(Handle->ActiveFrame)
  1712.                     {
  1713.                         *MsgClass    = IDCMP_GADGETUP;
  1714.                         *MsgGadget    = &Node->Special.Frame.Dummy;
  1715.  
  1716.                         Handle->ActiveFrame = NULL;
  1717.                     }
  1718.                 }
  1719.             }
  1720.  
  1721.             break;
  1722.         }
  1723.  
  1724.         case IDCMP_GADGETUP:
  1725.  
  1726.             #ifdef DO_LEVEL_KIND
  1727.             {
  1728.                 Handle->CurrentLevel = NULL;
  1729.             }
  1730.             #endif    /* DO_LEVEL_KIND */
  1731.  
  1732.             Handle->ActiveFrame = NULL;
  1733.  
  1734.             if(GETOBJECT((*MsgGadget),Node))
  1735.             {
  1736.                 if(Node->Type != LISTVIEW_KIND)
  1737.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  1738.  
  1739.                 switch(Node->Type)
  1740.                 {
  1741.                     case PASSWORD_KIND:
  1742.                     case STRING_KIND:
  1743.                     case FRACTION_KIND:
  1744.  
  1745.                         LTP_PutStorage(Node);
  1746.  
  1747.                         if(*MsgCode == 0x5F && Handle->HelpHook)
  1748.                         {
  1749.                             struct HelpMsg Message;
  1750.                             struct IBox Box;
  1751.  
  1752.                             Message.ObjectID = Node->ID;
  1753.  
  1754.                             Box.Left    = Node->Left;
  1755.                             Box.Top        = Node->Top;
  1756.                             Box.Width    = Node->Width;
  1757.                             Box.Height    = Node->Height;
  1758.  
  1759.                             Message.Handle = Handle;
  1760.  
  1761.                             CallHookPkt(Handle->HelpHook,&Message,&Box);
  1762.  
  1763.                             *MsgClass = NULL;
  1764.                         }
  1765.                         else
  1766.                             Handle->Previous = NULL;
  1767.  
  1768.                         break;
  1769.  
  1770.                     case INTEGER_KIND:
  1771.                     {
  1772.                         struct StringInfo *StringInfo = (struct StringInfo *)(*MsgGadget)->SpecialInfo;
  1773.                         LONG Contents = StringInfo->LongInt;
  1774.  
  1775.                         if(Contents < Node->Min)
  1776.                             Contents = Node->Min;
  1777.                         else
  1778.                         {
  1779.                             if(Contents > Node->Max)
  1780.                                 Contents = Node->Max;
  1781.                         }
  1782.  
  1783.                         LT_SetAttributes(Handle,(*MsgGadget)->GadgetID,GTIN_Number,Contents,TAG_DONE);
  1784.  
  1785.                         LTP_PutStorage(Node);
  1786.  
  1787.                         if(*MsgCode == 0x5F && Handle->HelpHook)
  1788.                         {
  1789.                             struct HelpMsg Message;
  1790.                             struct IBox Box;
  1791.  
  1792.                             Message.ObjectID = Node->ID;
  1793.  
  1794.                             Box.Left    = Node->Left;
  1795.                             Box.Top        = Node->Top;
  1796.                             Box.Width    = Node->Width;
  1797.                             Box.Height    = Node->Height;
  1798.  
  1799.                             Message.Handle = Handle;
  1800.  
  1801.                             CallHookPkt(Handle->HelpHook,&Message,&Box);
  1802.  
  1803.                             *MsgClass = NULL;
  1804.                         }
  1805.                         else
  1806.                             Handle->Previous = NULL;
  1807.  
  1808.                         break;
  1809.                     }
  1810.  
  1811.                     case CHECKBOX_KIND:
  1812.  
  1813.                         if(!V39)
  1814.                         {
  1815.                             if((*MsgGadget)->Flags & GFLG_SELECTED)
  1816.                                 *MsgCode = TRUE;
  1817.                             else
  1818.                                 *MsgCode = FALSE;
  1819.                         }
  1820.  
  1821.                         Node->Current = *MsgCode;
  1822.  
  1823.                         LTP_PutStorage(Node);
  1824.  
  1825.                         if(Handle->Previous && !Node->PageSelector)
  1826.                             Activate = TRUE;
  1827.  
  1828.                         break;
  1829.  
  1830.                     #ifdef DO_TAPEDECK_KIND
  1831.                     {
  1832.                         case TAPEDECK_KIND:
  1833.  
  1834.                             if(Node->Special.TapeDeck.Tick)
  1835.                             {
  1836.                                 Handle->ActiveIncrementer = NULL;
  1837.  
  1838.                                 *MsgClass    = IDCMP_GADGETUP;
  1839.                                 *MsgCode    = 1;
  1840.                             }
  1841.                             else
  1842.                             {
  1843.                                 if(Node->Special.TapeDeck.Toggle)
  1844.                                 {
  1845.                                     if((*MsgGadget)->Flags & GFLG_SELECTED)
  1846.                                         *MsgCode = TRUE;
  1847.                                     else
  1848.                                         *MsgCode = FALSE;
  1849.  
  1850.                                     Node->Current = *MsgCode;
  1851.  
  1852.                                     LTP_PutStorage(Node);
  1853.                                 }
  1854.                             }
  1855.  
  1856.                             if(Handle->Previous && !Node->PageSelector)
  1857.                                 Activate = TRUE;
  1858.  
  1859.                             break;
  1860.                     }
  1861.                     #endif    /* DO_TAPEDECK_KIND */
  1862.  
  1863.                     #ifdef DO_POPUP_KIND
  1864.                     {
  1865.                         case POPUP_KIND:
  1866.  
  1867.                             Node->Current = *MsgCode;
  1868.  
  1869.                             LTP_PutStorage(Node);
  1870.  
  1871.                             if(Handle->Previous && !Node->PageSelector)
  1872.                                 Activate = TRUE;
  1873.  
  1874.                             if(Node->Special.Popup.AutoPageID != -1)
  1875.                             {
  1876.                                 *MsgClass = NULL;
  1877.  
  1878.                                 if(!LTP_NotifyPager(Handle,Node->Special.Popup.AutoPageID,Node->Current))
  1879.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1880.                             }
  1881.  
  1882.                             break;
  1883.                     }
  1884.                     #endif
  1885.  
  1886.                     #ifdef DO_TAB_KIND
  1887.                     {
  1888.                         case TAB_KIND:
  1889.  
  1890.                             Node->Current = *MsgCode;
  1891.  
  1892.                             LTP_PutStorage(Node);
  1893.  
  1894.                             if(Handle->Previous && !Node->PageSelector)
  1895.                                 Activate = TRUE;
  1896.  
  1897.                             if(Node->Special.Tab.AutoPageID != -1)
  1898.                             {
  1899.                                 *MsgClass = NULL;
  1900.  
  1901.                                 if(!LTP_NotifyPager(Handle,Node->Special.Tab.AutoPageID,Node->Current))
  1902.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1903.                             }
  1904.  
  1905.                             break;
  1906.                     }
  1907.                     #endif
  1908.  
  1909.                     case CYCLE_KIND:
  1910.  
  1911.                         Node->Current = *MsgCode;
  1912.  
  1913.                         LTP_PutStorage(Node);
  1914.  
  1915.                         if(Handle->Previous && !Node->PageSelector)
  1916.                             Activate = TRUE;
  1917.  
  1918.                         if(Node->Special.Cycle.AutoPageID != -1)
  1919.                         {
  1920.                             *MsgClass = NULL;
  1921.  
  1922.                             if(!LTP_NotifyPager(Handle,Node->Special.Cycle.AutoPageID,Node->Current))
  1923.                                 *MsgClass = IDCMP_CLOSEWINDOW;
  1924.                         }
  1925.  
  1926.                         break;
  1927.  
  1928.                     case PALETTE_KIND:
  1929.  
  1930.                         Node->Current = *MsgCode;
  1931.  
  1932.                         LTP_PutStorage(Node);
  1933.  
  1934.                         if(Handle->Previous && !Node->PageSelector)
  1935.                             Activate = TRUE;
  1936.  
  1937.                         break;
  1938.  
  1939.                     case MX_KIND:
  1940.  
  1941.                         if(!V39 && Node->Disabled)
  1942.                         {
  1943.                             GT_SetGadgetAttrs(*MsgGadget,Handle->Window,NULL,
  1944.                                 GTMX_Active,Node->Current,
  1945.                             TAG_DONE);
  1946.  
  1947.                             *MsgClass = NULL;
  1948.                         }
  1949.                         else
  1950.                         {
  1951.                             Node->Current = *MsgCode;
  1952.  
  1953.                             LTP_PutStorage(Node);
  1954.  
  1955.                             if(Node->Special.Radio.AutoPageID != -1)
  1956.                             {
  1957.                                 *MsgClass = NULL;
  1958.  
  1959.                                 if(!LTP_NotifyPager(Handle,Node->Special.Radio.AutoPageID,Node->Current))
  1960.                                     *MsgClass = IDCMP_CLOSEWINDOW;
  1961.                             }
  1962.  
  1963.                             if(Handle->Previous && !Node->PageSelector)
  1964.                                 Activate = TRUE;
  1965.                         }
  1966.  
  1967.                         break;
  1968.  
  1969.                     case SLIDER_KIND:
  1970.  
  1971.                         if(Node->Min < 0)
  1972.                             Node->Current = (WORD)*MsgCode;
  1973.                         else
  1974.                             Node->Current = *MsgCode;
  1975.  
  1976.                         LTP_PutStorage(Node);
  1977.  
  1978.                         if(Handle->Previous && !Node->PageSelector)
  1979.                             Activate = TRUE;
  1980.  
  1981.                         break;
  1982.  
  1983.                     #ifdef DO_LEVEL_KIND
  1984.                     {
  1985.                         case LEVEL_KIND:
  1986.  
  1987.                             Node->Current = LTP_GetCurrentLevel(Node);
  1988.  
  1989.                             *MsgCode    = Node->Current;
  1990.                             *MsgGadget    = Node->Host;
  1991.  
  1992.                             LTP_PutStorage(Node);
  1993.  
  1994.                             LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  1995.  
  1996.                             break;
  1997.                     }
  1998.                     #endif    /* DO_LEVEL_KIND */
  1999.  
  2000.                     case SCROLLER_KIND:
  2001.  
  2002.                         Node->Current = *MsgCode;
  2003.  
  2004.                         LTP_PutStorage(Node);
  2005.  
  2006.                         if(Handle->Previous && !Node->PageSelector)
  2007.                             Activate = TRUE;
  2008.  
  2009.                         break;
  2010.  
  2011.                     case PICKER_KIND:
  2012.  
  2013.                         *MsgClass    = IDCMP_IDCMPUPDATE;
  2014.                         *MsgCode    = 0;
  2015.                         *MsgGadget    = Node->Special.Picker.Parent;
  2016.  
  2017.                         if(Handle->Previous && !Node->PageSelector)
  2018.                             Activate = TRUE;
  2019.  
  2020.                         break;
  2021.  
  2022.                     case INCREMENTER_KIND:
  2023.  
  2024.                         if(((ObjectNode *)Handle->ActiveIncrementer->Special.Incrementer.Parent->UserData)->Type == INTEGER_KIND)
  2025.                         {
  2026.                             *MsgGadget    = Handle->ActiveIncrementer->Special.Incrementer.Parent;
  2027.                             *MsgClass    = IDCMP_GADGETUP;
  2028.                             *MsgCode    = 1;
  2029.                         }
  2030.  
  2031.                         Handle->ActiveIncrementer = NULL;
  2032.                         break;
  2033.  
  2034.                     case LISTVIEW_KIND:
  2035.  
  2036.                         if(Node->Current != *MsgCode || Node != Handle->ClickObject)
  2037.                         {
  2038.                             CurrentTime(&Handle->ClickSeconds,&Handle->ClickMicros);
  2039.  
  2040.                             Handle->ClickObject = Node;
  2041.                         }
  2042.                         else
  2043.                         {
  2044.                             ULONG Seconds,Micros;
  2045.  
  2046.                             CurrentTime(&Seconds,&Micros);
  2047.  
  2048.                             if(DoubleClick(Handle->ClickSeconds,Handle->ClickMicros,Seconds,Micros))
  2049.                                 *MsgClass = IDCMP_IDCMPUPDATE;
  2050.  
  2051.                             Handle->ClickSeconds    = Seconds;
  2052.                             Handle->ClickMicros    = Micros;
  2053.                         }
  2054.  
  2055.                         Node->Current = *MsgCode;
  2056.  
  2057.                         LTP_PutStorage(Node);
  2058.  
  2059.                         if(Node->Special.List.AutoPageID != -1)
  2060.                             *MsgClass = NULL;
  2061.  
  2062.                         if(!LTP_NotifyPager(Handle,Node->Special.List.AutoPageID,Node->Current))
  2063.                             *MsgClass = IDCMP_CLOSEWINDOW;
  2064.  
  2065.                         if(Node->Special.List.Link)
  2066.                         {
  2067.                             Handle->Previous = Node->Special.List.Link;
  2068.  
  2069.                             if(!Node->PageSelector)
  2070.                                 Activate = TRUE;
  2071.                         }
  2072.                         else
  2073.                         {
  2074.                             if(Handle->Previous && !Node->PageSelector)
  2075.                                 Activate = TRUE;
  2076.                         }
  2077.  
  2078.                         break;
  2079.  
  2080.                     default:
  2081.  
  2082.                         if(Handle->Previous && !Node->PageSelector)
  2083.                             Activate = TRUE;
  2084.  
  2085.                         break;
  2086.                 }
  2087.             }
  2088.  
  2089.             break;
  2090.  
  2091.         case IDCMP_MOUSEMOVE:
  2092.  
  2093.             #ifdef DO_LEVEL_KIND
  2094.             {
  2095.                 if(Handle->CurrentLevel)
  2096.                     Node = Handle->CurrentLevel;
  2097.                 else
  2098.                     GETOBJECT((*MsgGadget),Node);
  2099.             }
  2100.             #else
  2101.             {
  2102.                 GETOBJECT((*MsgGadget),Node);
  2103.             }
  2104.             #endif /* DO_LEVEL_KIND */
  2105.  
  2106.             if(Node)
  2107.             {
  2108.                 if(Node->Type != LISTVIEW_KIND)
  2109.                     Handle->ClickSeconds = Handle->ClickMicros = 0;
  2110.  
  2111.                 switch(Node->Type)
  2112.                 {
  2113.                     case SCROLLER_KIND:
  2114.  
  2115.                         Node->Current = *MsgCode;
  2116.  
  2117.                         LTP_PutStorage(Node);
  2118.  
  2119.                         break;
  2120.  
  2121.                     case SLIDER_KIND:
  2122.  
  2123.                         if(Node->Min < 0)
  2124.                             Node->Current = (WORD)*MsgCode;
  2125.                         else
  2126.                             Node->Current = *MsgCode;
  2127.  
  2128.                         LTP_PutStorage(Node);
  2129.  
  2130.                         break;
  2131.  
  2132.                     #ifdef DO_LEVEL_KIND
  2133.                     {
  2134.                         case LEVEL_KIND:
  2135.  
  2136.                             Node->Current = LTP_GetCurrentLevel(Node);
  2137.  
  2138.                             *MsgCode    = Node->Current;
  2139.                             *MsgGadget  = Node->Host;
  2140.  
  2141.                             LTP_PutStorage(Node);
  2142.  
  2143.                             LTP_LevelGadgetDrawLabel(Handle,Node,FALSE);
  2144.  
  2145.                             break;
  2146.                     }
  2147.                     #endif    /* DO_LEVEL_KIND */
  2148.                 }
  2149.             }
  2150.  
  2151.             break;
  2152.  
  2153.         case IDCMP_ACTIVEWINDOW:
  2154.  
  2155.             if(Handle->Previous)
  2156.             {
  2157.                 Activate = TRUE;
  2158.  
  2159.                 *MsgClass    = IDCMP_GADGETDOWN;
  2160.                 *MsgCode    = 0;
  2161.                 *MsgGadget    = Handle->Previous;
  2162.             }
  2163.  
  2164.             break;
  2165.  
  2166.         case IDCMP_INACTIVEWINDOW:
  2167.  
  2168.             Handle->ActiveIncrementer = NULL;
  2169.             Handle->ActiveFrame = NULL;
  2170.             break;
  2171.     }
  2172.  
  2173.     if(Handle->AutoActivate && Activate && Handle->Previous)
  2174.     {
  2175.         if(GETOBJECT(Handle->Previous,Node))
  2176.         {
  2177.             if(!Node->Disabled)
  2178.             {
  2179.                 if(Node->Type == BOOPSI_KIND)
  2180.                 {
  2181.                     if(Node->Special.BOOPSI.ActivateHook)
  2182.                         CallHookPkt(Node->Special.BOOPSI.ActivateHook,(APTR)Handle,(APTR)Node->Host);
  2183.                 }
  2184.                 else
  2185.                     ActivateGadget(Handle->Previous,Handle->Window,NULL);
  2186.             }
  2187.         }
  2188.     }
  2189. }
  2190.